package com.njtoyo.taxi.admin.mapper.master.entity;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.njtoyo.taxi.admin.rest.pojo.dto.activity.orderCompletionReward.CustomerDetailSpecification;
import com.njtoyo.taxi.admin.rest.pojo.dto.activity.orderCompletionReward.DriverDetailSpecification;
import lombok.Data;

import java.util.Date;

@Data
public class DriverRegionActivityRule {
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    //乘客区域ID
    private Long driverRegionId;

    //0:新乘客注册
    private Integer activityCategory;

    //开始时间
    private Date startedAt;

    //结束时间
    private Date endedAt;

    //0:未开通,1:开通
    private Boolean isOpen;

    //具体配置
    private String detailSpecification;

    //创建时间
    private Date createdAt;

    //更新时间
    private Date updatedAt;


    @TableField(exist = false)
    private DriverDetailSpecification parsedDetailSpecification;

    public DriverDetailSpecification parseDetailSpecification() {
        if (this.detailSpecification == null || this.parsedDetailSpecification != null) {
            return this.parsedDetailSpecification;
        }
        DriverDetailSpecification driverDetailSpecification = JSON.parseObject(this.detailSpecification, DriverDetailSpecification.class);

        return driverDetailSpecification;
    }
}
